#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

int main ()
{
    pid_t id  = fork();
    if(id < 0){
        perror("fork");   //创建失败
        return 1;
    }

    else if(id == 0){   //child
        printf("i am child, pid = %d, ppid = %d\n",getpid(), getppid());
        sleep(5);
    }
    else{     //parent
        printf("i am parent, pid = %d, ppid = %d\n",getpid(), getppid());
        sleep(2);
        exit(0);
    }
    
    return 0;
}


